<template>
	<view style="position: relative;padding-bottom: 100rpx;font-size: 26rpx;">
		<view>
			<text>提交订单</text>
		</view>
		<view class="userbox">
			<view>名称：{{userobj.name}} <text class="btn" @click="nav(userobj)">为他人购买</text></view>
			<view>生日：{{userobj.birthday}}</view>
			<view>性别：{{userobj.sex}}</view>
			<view style="display: flex;">手机号：<up-text  mode="phone" :text="userobj.phone" format="encrypt"></up-text></view>
			
		</view>
		<view class="tcbox">
			<image class="tcimg" :src="lasttcobj.tc.src"></image>
			<view class="tcxqbox">
				<view>
		
					<text>
						{{lasttcobj.tc.title}}
					</text>

				</view>
				<view>

					<text style="color:lightgray;">套餐立减￥{{lasttcobj.tc.jian}}</text>
				</view>
			</view>
			<view>
				<text style="text-decoration: line-through;">￥{{lasttcobj.tc.price}}</text>
				<view style="margin-top: 20rpx;"> 
					<text >￥{{lasttcobj.tc.price-lasttcobj.tc.jian}}</text>
				</view>
			</view>
		
		</view>
		<view class="xqbox">
			<view>预约时间：{{lasttcobj.time}} {{lasttcobj.minute}}</view>
			<view>优惠卷：<text style="float: right;color:gray">暂无优惠券</text></view>
			<view><text style="float: right;">小计：￥{{lasttcobj.tc.price-lasttcobj.tc.jian}}</text></view>
		</view>
		<view class="userbox" style="height: 0%;">
			<view>支付方式 <text style="float: right;">微信支付</text></view>
			<view>是否开启消息通知 <radio color="orange" style="float: right;" @click="flag=!flag" :checked="flag"></radio></view>
		</view>
		<button class="yuyue" @click="()=>{
			submit(lasttcobj,userobj)
		}">立即预约</button>
	</view>

</template>

<script setup lang="ts">
	import request from "../../../components/promise/promise";
	import {ref} from 'vue'
	defineProps(['lasttcobj', 'userobj'])
	let flag=ref(false)
	let nav=(userobj:any)=>{
		uni.setStorageSync('activeobj',JSON.stringify(userobj))
		uni.navigateTo({
			url:`/pages/index/addpeople`,
		})
	}
	let submit=async(lasttcobj:any,userobj:any)=>{
		lasttcobj.buyid=userobj._id
		lasttcobj.buyname=userobj.name,
		lasttcobj.phone=userobj.phone
		lasttcobj.sex=userobj.sex
		lasttcobj.birthday=userobj.birthday
		lasttcobj.tz=flag.value
		console.log(lasttcobj,788)
		uni.setStorageSync('finishtc',JSON.stringify(lasttcobj))
		if(flag){
					await request({url:'http://47.93.162.7:3000/api/get_sms',method:"POST",data:{phoneNum:lasttcobj.phone,username:lasttcobj.buyname,time:lasttcobj.time,minute:lasttcobj.minute}})
		}
		uni.navigateTo({
			url:`/pages/index/finish`,
		})
	}
</script>

<style scoped>
	.yuyue {
		background: orange;
		border-radius: 50rpx;
		width: 50%;
		color: white;
		position: absolute;
		bottom: 0rpx;
		left: 180rpx;

	}

	.yuyue:active {
		color: silver;
	}

	.xqbox view {
		line-height: 80rpx;
	}

	.xqbox {
		height: 240rpx;
		width: 90%;
		margin: 0rpx auto;
		background: ghostwhite;
		padding: 20rpx 30rpx;
	}

	.tcxqbox {
		margin-left: -200rpx;
	}

	.tcxqbox text {
		font-size: 26rpx;
		line-height: 50rpx;
	}

	.tcimg {
		width: 100rpx;
		height: 100rpx;
		margin-right: 10rpx;
	}

	.btn {
		float: right;
		/* border: 1px solid orange; */
		font-size: 24rpx;
		line-height: 30rpx;
		height: 30rpx;
		padding: 10rpx;
		color: orange;
		margin-top: 10rpx;
	}

	.userbox view {
		line-height: 80rpx;
	}

	.userbox {
		height: 320rpx;
		width: 90%;
		margin: 30rpx auto;
		background: ghostwhite;
		padding: 20rpx 30rpx;
	}

	.tcbox {

		height: 100rpx;
		width: 90%;
		margin: 30rpx auto;
		background: ghostwhite;
		padding: 20rpx 30rpx;
		margin-bottom: 0rpx;

	}
</style>